<template>
	<view class="liveEnd">
		<c-layout>
			<view class="topBar">
				<u-icon name="close" size="34" @click="clickFinish"></u-icon>
			</view>
			<view class="anchorInfo">
				<view class="anchorImg">
					<image :src="$u.file.getMedieUrl(anchorInfo.anchorAvatar)" mode=""></image>
				</view>
				<view class="anchorName">
					{{anchorInfo.anchorName}}
				</view>
				<view class="anchorTitle">
					{{$t('liveBar.liveEnd')}}
				</view>
				<view class="anchorTime">
					<!-- <view class="">
						{{new Date(anchorInfo.endTime-anchorInfo.startTime).getMinutes()}}
					</view>	 -->	
					<view class="">
						{{anchorInfo.livesDuration}}
					</view>
					<view class="">
						{{$t('liveBar.live_time')}}
					</view>
					
				</view>
			</view>
			<view class="incomeBox">
				<view class="income">
					<view class="incomeTitle">
						{{$t('liveBar.this_income')}}
					</view>
					<view class="incomeNum">
						{{anchorInfo.salesAmount}}
					</view>
				</view>
			</view>
			<view class="dataBox">
				<view class="data" v-for="(item,index) in dataList" :key="index">
					<view class="num">
						{{item.num}}
					</view>
					<view class="title">
						{{item.title}}
					</view>
				</view>
			</view>
		</c-layout>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				dataList:[
					{
						title:this.$t("liveBar.sales"),
						num:''
					},
					{
						title:this.$t('liveBar.audience'),
						num:''
					},
					{
						title:this.$t('liveBar.order_num'),
						num:''
					},
					{
						title:this.$t('liveBar.gift'),
						num:''
					},
					{
						title:this.$t('liveBar.sales_volume'),
						num:''
					},
				],
				anchorInfo:'',
			}
		},
		onReady() {
			//阻止右滑返回
			plus.webview.currentWebview().setStyle({ popGesture: 'none' });
		},
		onLoad(option) {
			//主播结束直播获取直播数据

			// console.log('==============',this.startTime.split(' ')[1].split(':').splice(0,2).join(':'))

			console.log(option.anchorSessionId)
			uni.showLoading({
				title: this.$t('liveBar.Besettling')
			});
			setTimeout(()=>{
				this.$u.get(`/app/anchor/lives/settlementData/${option.anchorSessionId}`).then(res=>{
					console.log('直播结算',res)
					uni.hideLoading()
					// let startTime=res.data.startTime.split(' ')[1].split(':').splice(0,2).join(':')
					// let endTime=res.data.endTime.split(' ')[1].split(':').splice(0,2).join(':')
					this.anchorInfo=res.data
					this.dataList[0].num=res.data.salesVolume
					this.dataList[1].num=res.data.viewsNumber
					this.dataList[2].num=res.data.orderQuantity
					this.dataList[3].num=res.data.goldNum
					this.dataList[4].num=res.data.salesAmount
					
				})
							
			},2000)
				

		},
		methods: {
			clickFinish() {
				uni.navigateTo({
					url:"/pages/anchorConsole/anchorConsole"
				})
			},
			//点击查看
			settlement(){
				uni.navigateTo({
					url:"/pages/storyType/storeManagement/batchorders?type=anchor"
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.liveEnd {
		padding: 0 44rpx;
		.topBar {
			display: flex;
			justify-content: end;
			padding-top: 106rpx;
		}

		.anchorInfo {
			display: flex;
			flex-direction: column;
			align-items: center;
			margin-top: 110rpx;

			.anchorImg {
				width: 136rpx;
				height: 136rpx;
				border-radius: 50%;
				image{
					width: 100%;
					height: 100%;
					border-radius: 50%;
				}
			}

			.anchorName {
				height: 56rpx;
				font-size: 36rpx;
				font-family: HarmonyOS Sans SC-Regular, HarmonyOS Sans SC;
				font-weight: 400;
				color: #212121;
				line-height: 56rpx;
			}

			.anchorTitle {
				height: 56rpx;
				font-size: 36rpx;
				font-family: HarmonyOS Sans SC-Regular, HarmonyOS Sans SC;
				font-weight: 400;
				color: #212121;
				line-height: 56rpx;
			}

			.anchorTime {
				display: flex;
				text-align: center;
				height: 56rpx;
				font-size: 28rpx;
				font-family: HarmonyOS Sans SC-Regular, HarmonyOS Sans SC;
				font-weight: 400;
				color: #666666;
				line-height: 56rpx;
			}
		}
		.incomeBox{
			width: 100%;
			height: 216rpx;
			background-color: #f7f7f7;
			border-radius: 40rpx;
			padding: 0 40rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-top: 48rpx;
			.income{
				display: flex;
				height: 100%;
				padding: 40rpx 0;
				flex-direction: column;
				justify-content: space-evenly;
				.incomeTitle{
					font-size: 28rpx;
					font-weight: 400;
					color: #666666;
					line-height: 56rpx;
				}
				.incomeNum{
					font-size: 48rpx;
					font-weight: 700;
					color: #FFA800;
					line-height: 34rpx;
				}
			}
			
			.details{
				width: 112rpx;
				height: 58rpx;
				background-color: #2934D0;
				border-radius: 60rpx;
				color: #fff;
				font-size: 24rpx;
				line-height: 58rpx;
				text-align: center;
			}
		}
		.dataBox{
			width: 100%;
			height: 316rpx;
			background-color: #f7f7f7;
			border-radius: 60rpx;
			margin-top: 32rpx;
			display: flex;
			flex-wrap: wrap;
			align-items: center;
			.data{
				width: 33%;
				text-align: center;
				.title{
					font-size: 24rpx;
					font-family: Roboto-Regular, Roboto;
					font-weight: 400;
					color: #91909A;
					line-height: 34rpx;
				}
				.num{
					font-size: 40rpx;
					font-family: Roboto-Medium, Roboto;
					font-weight: 900;
					color: #000000;
					line-height: 56rpx;
				}
			}
		}
	}
</style>